package com.java.test1;

public class Rectangle {
	// 属性:定义了2个成员变量
	private double length;
	private double width;

	// 构造方法
	public Rectangle(double length, double width) {
		super();
		this.length = length;
		this.width = width;
	}

	// 行为
	/**
	 * (1)求面积
	 */
	public double getArea() {
		double i1 = 0.0;
		i1 = length * width;
		// System.out.println("输出正方形的面积为：" + s1);
		return i1;
	}

	/**
	 * (2)求周长
	 */
	public double getPer() {
		double i2 = 0.0;
		i2 = 2 * (length + width);
//		System.out.println("输出正方形的周长为：" + l1);
		return i2;
	}

	/**
	 * (3)输出长、宽、面积、周长
	 */
	public void showAll() {
		System.out.println("输出长为：" + this.length);
		System.out.println("输出宽为：" + this.width);
		System.out.println("输出正方形的面积为：" + this.getArea());
		System.out.println("输出正方形的周长为：" + this.getPer());
	}

	// getter，setter方法
	public double getLength() {
		return length;
	}

	public void setLength(double length) {
		this.length = length;
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

}
